package com.ray.util;



import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class ConfigUtil {

	private static Properties props = new Properties();
	private static String propertiesName;
	

	public static String getValue(String key) {
		return props.getProperty(key);
	}

	public static String getPropertiesName() {
		return propertiesName;
	}

	public static void setPropertiesName(String propertiesName) {
		ConfigUtil.propertiesName = propertiesName;
	}
	
	public static void init(){
		InputStream ips = ConfigUtil.class.getClassLoader()
				.getResourceAsStream(propertiesName);
		try {
			props.load(ips);
		} catch (IOException e) {
			System.out.println("读取"+propertiesName+"文件失败");
			e.printStackTrace();
		}finally {
			try {
				ips.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		setPropertiesName("config.properties");
		ConfigUtil.init();
		String token=ConfigUtil.getValue("wxToken");
		System.out.println(token);
	}

}
